#include "stdafx.h"
#include "ui_recentfiles.h"

#include "pf_debug.h"

/**
 * Constructor
 * @param number Number of files that can be stored in the list at maximum
 */
UI_RecentFiles::UI_RecentFiles(int number) {
    this->number = number;
}


/**
 * Destructor
 */
UI_RecentFiles::~UI_RecentFiles() {}

/**
 * Adds a file to the list of recently loaded files if 
 * it's not already in the list.
 */
void UI_RecentFiles::add(const QString& filename) {
	PF_DEBUG->print("UI_RecentFiles::add");
	
    // is the file already in the list?
    if (files.find(filename) != files.end()) {
        return;
    }

    // append
    //files.push_back(filename);
    files.append(filename);
    if ((int)files.count() > number) {
        // keep the list short
        files.pop_front();
    }

    //for (int i=0; i<(int)files.count(); ++i) {
    //	printf("recent file[%d]: %s\n", i, files[i].latin1());
    //}
	PF_DEBUG->print("UI_RecentFiles::add: OK");
}


